package com.api.gbhg.zengping.web;

import com.alibaba.fastjson.JSON;
import com.api.gbhg.daiyanlu.api.PrintCopyActionApi;
import com.api.gbhg.daiyanlu.api.SixteenActionApi;
import com.api.gbhg.hzz.SubScribeContorller;
import com.api.gbhg.lbj.api.GeneralProjectApi;
import com.api.gbhg.liubing.web.EducationTrainingAction;
import com.api.gbhg.liubing.web.EndowmentInsuranceAction;
import com.api.gbhg.liubing.web.NotForContractWorkersAction;
import com.api.gbhg.liuwenbo.api.OfficeSuppliesApi;
import com.api.gbhg.luoao.web.CauseRetirementPayAction;
import com.api.gbhg.luoao.web.CauseWageAllowanceAction;
import com.api.gbhg.luoao.web.PublicBookApprovalAction;
import com.api.gbhg.zengping.common.CommonDao;
import com.api.gbhg.zengping.dao.PropertyManagementCostDao;
import com.api.gbhg.zengping.dao.RetiredPeopleDao;
import com.api.gbhg.zengping.page.PageInfo;
import org.apache.axis.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import weaver.conn.RecordSetTrans;

import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
import java.util.Map;

/**
 * @program: gbhg-oa
 * @description: 预算核批列表
 * @author: Mr.zeng
 * @create: 2021-02-01 17:49
 **/
public class BudgetHPAction {

    public static final Logger LOGGER = LoggerFactory.getLogger("gbhg");
    /**
     * 操作sql类
     */
    private final PropertyManagementCostDao rmcd=new PropertyManagementCostDao();
    private final RetiredPeopleDao getRpd=new RetiredPeopleDao();

    /**
     * 预算核批列表
     * @param param
     * @return
     */
    @POST
    @Path("/getBudgetHpList")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    public String getBudgetHpList(Map<String,String> param) {
        // 得到核批状态 3就是已核批  非3就是待核批
         String requestId = param.get("requestId");
        PageInfo<String> pageInfo=new PageInfo();
        pageInfo.setList(new Map[0]);
        if(StringUtils.isEmpty(requestId)){
            return JSON.toJSONString(pageInfo);
        }
        String hpzt = param.get("hpzt");
        //未审核
        if(null!=hpzt&&hpzt.equals("0")){
            //过滤一遍requestId，让其都处于预算审核节点
            requestId = new CommonDao().getYSHPRequestId(requestId);
            if(StringUtils.isEmpty(requestId)){
                return JSON.toJSONString(pageInfo);
            }
        }
        LOGGER.info("物业核批列表参数："+requestId);
        RecordSetTrans rst = rmcd.getSBInfo(requestId);
        Map<String,Object>[] map=new HashMap[rst.getArray().size()];
        int i=0;
        //判断 流程标记  lcbj
        String lcbj = param.get("lcbj");
        switch (lcbj){
            case "01":
                //01 海关离退休人员工资津贴补贴经费新增表
                return new RetiredPeopleAction().retiredPeople1(requestId);
            case "02":
                // 02 通用项目新增表
                return new GeneralProjectApi().getGeneralProjecData1(requestId);
            case "03":
                //03.物业费核批
                return new PropertyManagementAction().PropertyManagement1(requestId);
            case "04":
                // 04 办公用品定额包干经费需求表
                HashMap<String,Object> hashMap=new HashMap<>();
                hashMap.put("requestId",requestId);
                return new OfficeSuppliesApi().getDataArray(hashMap);
            case "05":
                // 05 拱北海关报刊订阅审批表
                return new SubScribeContorller().qrySubScribeInfo1(requestId);
            case "06":
                // 06 拱北海关报刊订阅审批表（年度增订）
                return new SubScribeContorller().qryAddSubScribeInfo1(requestId);
            case "07":
                // 07 不占编合同工劳务费需求表
                return new NotForContractWorkersAction().getNotForContractWorkersAction1(requestId);
            case "08":
                // 08 复印纸、打印纸用量需求表
                return new PrintCopyActionApi().getPrintCopy1(requestId);
            case "09":
                // 09 公共图书馆、阅览室订阅审批表
                return  new PublicBookApprovalAction().pbal1(requestId);
            case "10":
                // 10 教育培训经费
                return new EducationTrainingAction().getEducationTrainingAction1(requestId);
            case "11":
                // 11 海关在职行政人员工资津补贴经费需求表
                return new JobAdministrationAction().jobAdministrationBatch1(requestId);
            case "12":
                // 12 警察在职行政人员工资津贴补贴经费需求表
                return new SubScribeContorller().qryPoliceMoneyApply1(requestId);
            case "13":
                // 13 事业单位离退休人员工资津贴补贴经费需求表
                return new CauseRetirementPayAction().cpapi1(requestId);
            case "14":
                // 14 事业单位在职人员工资津贴补贴经费需求表
                return new CauseWageAllowanceAction().CauseWageAllowance1(requestId);
            case "15":
                // 15 海关养老保险缴费经费需求表
                return new EndowmentInsuranceAction().getEndowmentInsuranceAction1(requestId);
            case "16":
                // 16 海关医疗保险缴费经费需求表
                return new SixteenActionApi().getSixteen1(requestId);
            case "17":
                // 17 住房改革支出经费需求表
                return new SubScribeContorller().qryHousingInfo1(requestId);
            default:
        }
        return null;
    }

    public static void main(String[] args) {
        if(!StringUtils.isEmpty("1")){
            System.out.println("1");
        }

    }
}
